package com.have.blog.web.service.impl;

import com.github.pagehelper.PageHelper;
import com.have.blog.base.enums.BlogStatus;
import com.have.blog.model.mapper.OuterLinkMapper;
import com.have.blog.model.models.OuterLink;
import com.have.blog.model.models.OuterLinkExample;
import com.have.blog.web.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@SuppressWarnings("all")
public class LinkServiceImpl implements LinkService {

    @Autowired
    private OuterLinkMapper linkMapper;

    @Override
    public List<OuterLink> getListByPageSize(Integer pageSize) {
        PageHelper.startPage(1, pageSize);
        OuterLinkExample example = new OuterLinkExample();
        example.createCriteria()
                .andStatusEqualTo(BlogStatus.ENABLE.getStatus())
                .andLinkStatusEqualTo(BlogStatus.ENABLE.getStatus());
        example.setOrderByClause("sort desc");
        List<OuterLink> links = linkMapper.selectByExample(example);
        return links;
    }
}
